<?php
/**
 *
 * @package avp
 * @version $Id: $
 * @copyright (c) 2006 Jan-Willem van Ganswijk, Stefan van Essen
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */
if( !defined( 'IN_SCRIPT' ) ) {
    die();
}

define('FALLBACK_LANG','en');

function read_langfiles( $files ) {
    global $root, $CONFIG;

    $active_lang = $CONFIG['lang'];

    if(!is_dir("{$root}lang/{$active_lang}")) {
		$active_lang = FALLBACK_LANG;
	}

    include( "{$root}lang/{$active_lang}/conf.lang.php" );
    $files = explode( ",", $files );

    $CONFIG['lang_name_short'] = $lang['name_short'];
    $CONFIG['lang_name'] = $lang['name'];
    $CONFIG['lang_version'] = $lang['version'];

    $lang = array();
    foreach( $files as $file ) {
        if( is_readable( "{$root}lang/{$active_lang}/{$file}.lang.php" ) ) {
            include( "{$root}lang/{$active_lang}/{$file}.lang.php" );
        } elseif( is_readable( "{$root}lang/{$fallbacklang}/{$file}.lang.php" ) ) {
            include( "{$root}lang/{$fallbacklang}/{$file}.lang.php" );
        }
    }
    return $lang;
}

function get_langdetails( $language ) {
    global $root;
    require( "{$root}lang/{$language}/conf.lang.php" );
    return $lang;
}

?>